To learn about the SQL Wizard, and replicate the process of creating a ForEach table with a simple selection of 4 columns of data through the creation of an employee photo directory.
Up until this point, you most likely have been selecting only one table at a time for your ForEach tags and had no way of sorting or filtering your data. The SQL Wizard is a very powerful tool that can aid you in your quest for the ultimate data (and to please your boss with a good report)! Here you will learn the basics of the SQL Wizard, and your knowledge can only expand after this.
Load the MSSQL datasource by clicking the bottom half of the "Data Sources" button, and selecting MSSQL. If there is no MSSQL option in the drop down menu, you may select another datasource, or follow the instructions in the Creating a SQL Datasource tutorial.
Open the Insert menu in Word, and click the Table button to insert a table. Select a 3X2 table. In the interest of spicing this design up in the simplest way possible, we’re going to select a table style from the menu that pops up (if you lose it, it’s one of the highlighted Table Tools ribbons, called Design) The styles are right in the center of the ribbon. We chose the third one called Plain Table 1
Now, we’re going to go ahead and name the columns. Employee, Phone, and Photo are the names we use since we’re going to try to make a photo directory for the companies employees.
Now we’ll insert a ForEach tag, just as before. Open the AutoTag ribbon, find the Tags button and select the ForEach tag. We’ll give it a nickname, [forEach Employee: and a variable name:employee Also insert 4 out tags (two under the “Employee” column for a first and last name) and an End ForEach tag using the same device.
To do this, select the ForEach tag you just created, and under the AutoTag ribbon, click the Wizard button. This pops up a window called the SQL Wizard. Feel free to take a look around. We’ll explain what everything does in step 7.
In the middle pane, there is a box labeled Columns. We need to drag any data we want to work with to this box. This data will later be accessible by the out tags inside the ForEach tag we are working on. We’re going to go ahead and drag in the HomePhone, PostalCode and Photo.
We actually don’t need PostalCode, but we added it so we can demonstrate how to remove columns you don’t need. To do this, simply click the desired column with your left mouse button and select remove. Finally for this step, insert the FirstName and LastName columns at the top.
There are three main components you should take a look at here. The left pane holds all of your data, and the right pane holds the returned results (which includes any sorting or filtering you may apply). The middle pane has boxes labeled Columns, Sort, Filter and Join Tables.
If you take a look at the tutorial listing, we have tutorials to exclusively cover operations in each of these boxes, but the run down is as follows: Columns is where you drag data you want to work with, Sort is where you drag data you want to sort by, Filter is where you create conditions to filter your data and Join Tables is really an informational box that shows how tables have been automatically joined.
All we have left to do is set the out tags to display the data we just found in the SQL Wizard. Hopefully you have lots of practice in this already since you’ve done it in nearly every tutorial so far. Click the tag, open the Data tree and select a piece of data. With the SQL Wizard, we have only returned 4 columns which means the Data tree is a lot simpler to look at now!
You should be well versed in this step as well. If you have any problems here, please take a look at some of the tutorials under AutoTag Basics
You have completed this tutorial. We recommend taking a look at the SQL - Part 2: Sorting tutorial next!